package com.zat.mes.andrmes.dofun.work


import android.text.TextUtils
import android.view.View
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.zxing.common.StringUtils
import com.zat.mes.andrmes.R
import com.zat.mes.andrmes.base.BaseActivity
import com.zat.mes.andrmes.dofun.work.adapter.GetBomNotifiAdapter
import com.zat.mes.andrmes.dofun.work.adapter.GetBomNotifiDetailAdapter
import com.zat.mes.andrmes.dofun.work.vm.GetBomNotifiModel
import com.zat.mes.andrmes.utils.showToast
import kotlinx.android.synthetic.main.activity_get_bom_notifi.*
import kotlinx.android.synthetic.main.activity_get_bom_notifi_detail.*
import kotlinx.android.synthetic.main.layout_title.*

class GetBomNotifiDetailActivity : BaseActivity() {

    var getBomNotifiModel: GetBomNotifiModel? = null
    var getBomNotifiDetailAdapter: GetBomNotifiDetailAdapter? = null
    override fun init() {
        initView()
        initData()
    }

    private fun initData() {
        getBomNotifiModel = ViewModelProvider(this).get(GetBomNotifiModel::class.java)
        getBomNotifiModel?.getOrderBomDetailList()?.observe(this, Observer {
            closeLoading()
            getBomNotifiDetailAdapter?.setNewData(it)
        })

        showLoading()
        getBomNotifiModel?.getOrderBomDetail(intent.getStringExtra("yarnInformNo"))

    }

    private fun initView() {
        setContentView(R.layout.activity_get_bom_notifi_detail)
        tVtitle.text = "原料领用通知单详情"
        rlReturnTitle.visibility = View.VISIBLE
        rlReturnTitle.setOnClickListener { finish() }
        rvBomNotifiDetail.layoutManager = LinearLayoutManager(this)
        getBomNotifiDetailAdapter = GetBomNotifiDetailAdapter(R.layout.item_get_bom_notifi_detail)
        rvBomNotifiDetail.adapter = getBomNotifiDetailAdapter
        rvBomNotifiDetail.addItemDecoration(
            DividerItemDecoration(
                this,
                DividerItemDecoration.VERTICAL
            )
        );

    }
}